package com.matrix.java.chap_06;

import java.util.Scanner;

/*
    指定字符的出现次数
 */
public class  Ex6_23 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("输入: ");
        String str = input.next();
        String a = input.next();
        input.close();
        System.out.println(count(str, a.charAt(0)));
    }

    private static int count(String str, char a) {
        int count = 0;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == a) {
                count++;
            }
        }
        return count;
    }
}
